package com.zzptc.sky.bdsjws.activites;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.Toast;

import com.zzptc.sky.bdsjws.MyApplication;
import com.zzptc.sky.bdsjws.R;
import com.zzptc.sky.bdsjws.activites.base.BaseActivity;
import com.zzptc.sky.bdsjws.adapter.Baoxiang_Adapter;
import com.zzptc.sky.bdsjws.db.BbxDao;
import com.zzptc.sky.bdsjws.db.DaoSession;
import com.zzptc.sky.bdsjws.listener.OnRecyclerItemClickListener;
import com.zzptc.sky.bdsjws.utils.DividerGridItemDecoration;
import com.zzptc.sky.bdsjws.vo.Bbx;
import org.greenrobot.greendao.query.QueryBuilder;
import java.util.List;
import butterknife.BindView;

public class Baoxiang extends BaseActivity {
    static DaoSession daoSession;
    List<Bbx> list;
    Baoxiang_Adapter baoxiang_adapter;
    @BindView(R.id.bx_rv)
    RecyclerView bxRv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    public int getContentView() {
        return R.layout.activity_baoxiang;
    }

    @Override
    public void initData() {
        BbxDao bbxDao = MyApplication.getDaoSession().getBbxDao();
        final List<Bbx>  list= bbxDao.loadAll();
        //用RecyclerView显示数据
        Baoxiang_Adapter baoxiang_adapter=new Baoxiang_Adapter(list);
        RecyclerView.LayoutManager layoutManager=new GridLayoutManager(this,4);
        bxRv.setLayoutManager(layoutManager);
//        bxRv.addOnItemTouchListener(new OnRecyclerItemClickListener());
        bxRv.addItemDecoration(new DividerGridItemDecoration(this));
//        baoxiang_adapter=new Baoxiang_Adapter(list);
        bxRv.setAdapter(baoxiang_adapter);
//        bxRv.addOnItemTouchListener(new OnRecyclerItemClickListener(bxRv){
//            @Override
//            public void onItemClick(RecyclerView.ViewHolder vh) {
//                super.onItemClick(vh);
//                Bbx bbx=list.get(vh.getLayoutPosition());
//                //Toast.makeText(Baoxiang.this,bbx.getName(), Toast.LENGTH_SHORT).show();
//                if(bbx.getName().equals("家人守护")){
//                    startActivity(new Intent(Baoxiang.this,FamilyProtectActivity.class));
//                }else if(bbx.getName().equals("")){
//
//                }
//            }
//
//            @Override
//            public void onLongClick(RecyclerView.ViewHolder vh) {
//                super.onLongClick(vh);
//            }
//        });
//
  }

    @Override
    public void initView() {

    }
}
